
var app = sm('do_App');
var page = sm("do_Page");
var service_url = sm("do_Global");
var url  = service_url.getMemory("service_url");
//定义UI组件
var back_btn = ui("do_Button_Cancel");
var do_Button_forward = ui("do_Button_forward");
var mData = page.getData();
var cacher = sm("do_DataCache");
//点击下一步跳转界面
do_Button_forward.on("touch", function() {
	
	
	app.openPage("source://view/storedvalue/storedvaluedetailsuccess.ui");
	storeValue();
	
	
});

function storeValue(){
	var http = mm("do_Http");
	http.method = "POST";
	http.timeout = 30000;
	http.contentType = "application/json";
	http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	var token = cacher.loadData("token");
	http.setRequestHeader("Cookie", token+"");
	http.url = url+"index.php?s=/admin/member/addmemberaccount";
	//s	/admin/member/addmemberaccount
	//http.body = "id="+mData.uid+"&type=2&num="+mData.valueStore;
	http.body = {
			"id":mData.uid,
			"type":"2",
			"num":mData.valueStore
	}
	http.on("success", function(data) {
		//nf.toast(data);
		//将数据添加到组件中
		deviceone.print(JSON.stringify(data),"data");
		if(data.code==1){
			app.openPage({
				source:"source://view/storedvalue/storedvaluedetailsuccess.ui", 
				data:mData
				});
		}else{
			nf.toast("操作失败");
		}
		
	});
	http.request();
}



page.on('loaded',function(){
	ui('acount').text = mData.user_name;
	ui('name').text = mData.nick_name;
	ui('add').text = mData.location;
	ui('phone').text = mData.user_tel;
	ui('money').text = mData.valueStore;//储值金额
	ui('moneyType').text = "暂无优惠";
	ui('moneyvalue').text = mData.valueStore;
	ui('resmoney').text = mData.balance;
	//ui('time').text = formatDateTime(mData.current_login_time);
});
page.on('back',function(){
	app.closePage(page);
});

/*****返回按钮*****/
back_btn.on("touch",function(){
	app.closePage(page);
});

